package com.awphone.data;

import com.awphone.data.constant.EObjectType;
import com.awphone.data.constant.EPhoneType;
import com.awphone.data.constant.NXXConst;

import javax.persistence.*;

/**
 * @author a_polyakov
 * Date: 03.03.13
 * Time: 22:35
 * Телефонный код штата + префикс
 */
@Entity
@Table(schema = NXXConst.SCHEMA_NAME, name = NXXConst.TABLE_NAME)
public class NXX extends AbstractObject {
    /**
     * Телефонный код штата
     */
    private NPA npa;
    /**
     * Город
     */
    private City city;
    /**
     * Оператор
     */
    private Company company;
    /**
     * Тип телефонов (Стационарный, мобильный)
     */
    private EPhoneType phoneType;

    {
        setObjectType(EObjectType.NXX);
    }

    public NXX() {
    }

    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(name = NXXConst.S_NPA, nullable = false, updatable = false)
    public NPA getNpa() {
        return npa;
    }

    public void setNpa(NPA npa) {
        this.npa = npa;
    }

    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(name = NXXConst.S_CITY, nullable = false, updatable = false)
    public City getCity() {
        return city;
    }

    public void setCity(City city) {
        this.city = city;
    }

    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(name = NXXConst.S_COMPANY, nullable = false, updatable = false)
    public Company getCompany() {
        return company;
    }

    public void setCompany(Company company) {
        this.company = company;
    }

    @Column(name = NXXConst.S_PHONE_TYPE)
    @Enumerated(EnumType.STRING)
    public EPhoneType getPhoneType() {
        return phoneType;
    }

    public void setPhoneType(EPhoneType phoneType) {
        this.phoneType = phoneType;
    }
}
